package com.example.demo.demo;

import com.example.demo.po.AdminRequest;

import java.io.*;

public class SerialDemo implements Serializable {

    public static void main(String[] args) throws Exception {
        // 测试序列化
        AdminRequest adminRequest = new AdminRequest();
        adminRequest.setRequestNo("123123123123");
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(new File("E:/AdminRequest.txt")));
        oos.writeObject(adminRequest);
        System.out.println("Student对象序列化成功！");
        oos.close();

        // 测试反序列化
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream(new File("E:/AdminRequest.txt")));
        AdminRequest adminRequest2 = (AdminRequest) ois.readObject();
        System.out.println(adminRequest2.getRequestNo());
        System.out.println("Student对象反序列化成功！");
    }

}
